/*-------------------------------------------------------------------------

***************** Modification History ***********************************
   @doc
   @module Define.h -  Header file for application level defines |
   @end
   
**************************************************************************

   Copyright (C) 1999 by VeriFone, Inc.

   All rights reserved.  No part of this software may be reproduced,
   transmitted, transcribed, stored in a retrieval system, or translated
   into any language or computer language, in any form or by any means,
   electronic, mechanical, magnetic, optical, chemical, manual or otherwise,
   without the prior written permission of VeriFone, Inc.

---------------------------------------------------------------------------*/

#ifndef DEF_DEFINED
#define DEF_DEFINED

#include <SVC.H>
#include <portdef.h>
/* Transaction types */

#define ADMIN_TRAN            -1
#define CREDIT_TRAN            0
#define DEBIT_TRAN             1
#define ADJUST_CREDIT_TRAN     2
#define ADJUST_DEBIT_TRAN      3
#define AUTH_CREDIT_TRAN       4
#define AUTH_DEBIT_TRAN        5
#define CHECK_DEBIT_TRAN       6 

/* Card Types */

#define ADMIN_CARD          -1
#define CREDIT_CARD         0
#define DEBIT_CARD          1
/* ALL_TOTALS is 2............ */
#define NON_CARD            3
#define LOYALTY_CARD        6       /* Loyalty Only Card */
#define LOYCREDIT_CARD      7       /* Loyalty & Credit Card Combo */
#define EBT_CARD            8
#define PURCHASE_CARD       9 
#define COMMERCIAL_CARD     10
#define FLEET_CARD          11


/* Baud Rates For Communicating */
#define BAUD_300     0
#define BAUD_600     1
#define BAUD_1200    2
#define BAUD_2400    3
#define BAUD_4800    4
#define BAUD_9600    5
#define BAUD_19200   6
#define BAUD_38400   7
#define AUTO_BAUD    8


/* PinPad Baud Rates */
#define PPAD_BAUD_1200    2
#define PPAD_BAUD_2400    3
#define PPAD_BAUD_4800    4
#define PPAD_BAUD_9600    5

/* PinPad Data Format */
#define PPAD_FORMAT_7E1    0
#define PPAD_FORMAT_8N1    4

/* Protocol Specifications */
#define CHAR_MODE           P_char_mode
#define PACKET_MODE         P_pakt_mode
#define SDLC_MODE		    P_sdlc_mode
#define SDLC_SEC_MODE       P_sdlc_sec
#define SDLC_SEC_PFAST      P_sdlc_pfast

/* Host Ids */
#define NPC_HOST            2

/* Different host types */

#define NONCARD_HOST          -999
#define INV_HOST               0
#define ISO_HOST               1
#define VF_HOST                2
#define SPDH_HOST              3
#define VISA1_HOST             4

#define NO_HOST_SUBTYPE         0
#define AMEX_HOST_SUBTYPE       1
#define ACI_BASE24_HOST_SUBTYPE 2

/* Track Numbers */
#define TRACK_ONE    1
#define TRACK_TWO    2
#define TRACK_THREE  3

/* CVV2 Type Defines */
#define NO_CVV2                0
#define CVV2_CARD_NOT_PRESENT  1
#define CVV2_CARD_EITHER       2

/* Values for chip status flag */
#define NOT_USING_CHIP       0
#define EMV_CARD             1
#define EMV_EASY_ENTRY_CARD  2
#define IMAM_MSD_TAP_CARD     3  //PAYPASS
#define IMAM_CHIP_TAP_CARD    4  //VISAWAVE
#define EMV_TABLE_NOT_USED  -1 

/* Code on Back Key */
#define KEY_CODE_ON_BACK_NO        1
#define KEY_CODE_ON_BACK_XREAD     2

/* CVV2 Presence Indicator */
#define CVV2_VALUE_SKIP        '0'
#define CVV2_VALUE_PRESENCE    '1'
#define CVV2_ILLEGIBLE         '2'
#define CVV2_NOT_ON_BACK       '9'


/* Clerk Mode Functionality */
#define NO_CLERK     0        /* No Clerk Or Server */
#define CLERK_LGN    1        /* Allow Clerk Logon */
#define CLERK_PROMPT 2        /* Prompt for Clerk Or Server */

/* Shift definitions used in multiple files */

#define NO_SHIFT        0
#define AUTO_SHIFT      1
#define MANUAL_SHIFT    2


                              /* Each Financial Txn Flow */
/* Fraud Control Options */
#define NO_FC        0        /* Fraud Control Disabled */
#define FC_LAST4     1        /* Enter last 4 digits account number */
#define FC_DISPLAY   2        /* Display MSR account number */
#define FC_BOTH      3        /* Do both */

/* AVS Options */
#define NO_AVS       0        /* AVS Disabled */
#define AVS_ZIPCODE  1        /* Enter Zip Code */
#define AVS_ADDRESS  2        /* Enter Address */
#define AVS_BOTH     3        /* Enter both */

/* APPLICATION Types */
#define RETAIL       0
#define RESTAURANT   1

/* SETTLEMENT Types */
#define NO_DISPLAY            0        /* Disabled */
#define CONFIRM_SETTLE_TOTALS 1        /* Confirm settlement totals */
#define ENTER_SETTLE_TOTALS   2        /* Enter settlement totals */

/* Debit Allowed    */

#define NODEBIT     0
#define DEBIT       1


/* PINPad Types */
#define NO_PINPAD   0 
#define PP101       1   /* Supports Master/Session */
#define PP1000      2   /* Supports Master/Session + DUKPT + MAC'ing */
#define PP102       3   /* Supports DUKPT */
#define IPP         4   /* Supports Master/Session + DUKPT + MAC'ing */
#define PP501       5   /* Supports Master/Session + DUKPT + MAC'ing */
#define SC552       6   /* PinPad + 2 SmartCard Reader/Writers + MSR */
#define PP201       7   /* Supports Master/Session + MSR */
#define PP2000      8   /* Supports Master/Session + DUKPT + MAC'ing + MSR */
#define SC455       9   /* PinPad + SmartCard Reader/Writer, supports Master/Session + DUKPT */

/* Encryption Method */
#define MASTER_KEY  0
#define DUKPT       1


/* FPS Type Defines */
#define FPS_NO      0
#define FPS_FLOOR   1
#define FPS_VISA_EXP 2		/* VISA Express Payment Service */
#define FPS_MC_QUICK 3		/* MasterCard Quick Payment Service */
#define FPS_AX_QRS   4      /* American Express QRS */
#define FPS_CUSTOM	 5		/* Custom Fast Payment Service */

/* Print Options */
#define PRT_NONE           0
#define PRT_PROMPT         1
#define PRT_CUST           2
#define PRT_MERCH          4
#define PRT_BOTH_CONF_CUSTCOPY  10
#define PRT_BOTH_AUTO_CUSTCOPY  18
#define PRT_DUPLICATE     32
#define PRT_ERROR         64

#define PRT_NO_CUST_COPY   0
#define PRT_CUST_CONFIRM   1
#define PRT_CUST_AUTO      2


/* Multi Merchant */
#define MAX_MERCHS          15

#define DOWNLINE_LOAD_FNAME "VSDWN"

#define CONTINUE            (1)             /* Loop Control */

#define VS_SUCCESS            0             /* General purpose error code */
#define VS_ERR              (-1)
#define VS_ERROR            (-1)            /* Operator error */
#define VS_FAILURE          (-2)            /* System-level error */
#define VS_ESCAPE           (-3)            /* Operator quit transaction */
#define VS_TIMEOUT          (-4)            /* Time out */
#define VS_CARRIER          (-5)            /* Modem Lost Carrier */
#define VS_EOB              (-6)            /* End of Batch */
#define VS_ABORT            (-99)           /* Operation Aborted (obsolete) */

#define FHANDLE         int

typedef char VS_BOOL;
//#ifndef __SP_BYTE__
//typedef char byte;
//#define __SP_BYTE__
//#endif

typedef int (*PFI)();
typedef int (*PFS)();
typedef int (*PFI_VD)(void *);
typedef int (*PFI_PSZ)(char *);
typedef int (*PFI_VOID)(void);


typedef void  (*PFV_VD)(void *);
typedef int (*PFI_PFOR_SEND)(void *, char *, int , VS_BOOL, int , long ); 
typedef int (*PFI_PFOR_RES)(void *, char *, int ,  int , long ); 
typedef int (*PFI_PFOR_BEGIN)(void *, int , VS_BOOL); 
typedef short (*PFI_VOID_CHAR)(void * , char *);
typedef int (*PFI_PVOID_INT)(void * , int);
typedef int (*PFI_SH_PSZ)(short, char *);
typedef int (*PFI_VD_INT)(void *, int);
typedef int (*PFI_INT_SH) (int ,unsigned short);
typedef int (*PFI_INT_INT) (int ,unsigned int);
typedef int (*PFI_VD_CHAR_BOOL) (void *, char *, VS_BOOL);
//typedef int (*PFI_INT) (int);

#define VS_FALSE           ((VS_BOOL) 0)
#define VS_TRUE            ((VS_BOOL) 1)

#define NULL_PFI            ((PFI) 0)
#define NO_ACCESS           ((PFI) 1)

/***************** sprintf, printf etc substitutions *********************************************/

#define SUBSTITUTE_LD  szLongStr
#define SUBSTITUTE_D   szIntStr
extern char szLongStr[];
extern char szIntStr[];

/***************** Acount types *********************************************/
#define DEFAULT_ACCT       '0'
#define CHEQUE_ACCT        '1'
#define SAVINGS_ACCT       '2'
#define CREDIT_ACCT        '4'

/***************** Reversal Specific Types **************************************/
#define CONTROLLER_REVERSAL     0
#define DECRYPTION_REVERSAL     1
#define MAC_REVERSAL            2

/***************** Tip Processing Types **************************************/
#define TIP_OFF                 0
#define TIP_ON_PROMPT           1
#define TIP_ON_NO_PROMPT        2


/******************** Globally defined constants ***************************/
#define NULL_CH            ((char) 0)

#include <sizes.h>

/**************** Duplicate Check Data Structure ******************************/
typedef struct 
{
    char szPAN[PAN_SIZE + 1];           /* Account number */
    long lnTotalOfTransactionAmount;    /* The sum of the "transaction amount" plus any modifiers such as TIP.*/
    int  inCode;                        /* Trans Code */
} DUPCHK;

/**************** Datapac communication defines ******************************/

#define PUBLIC_3101              0
#define PRIVATE_3101             1
#define BINARY_MODE              0
#define TEXT_MODE                1

/* Electronic Commerce Indicator (ECI) Type Defines */
#define NO_ECI                  0
#define ECI_PROMPT_ENCRYPT      1
#define ECI_TYPE_SECURED        2
#define ECI_TYPE_NON_SECURED    3
#define ECI_TYPE_SET_NO_CERT    4
#define ECI_TYPE_SET_WITH_CERT  5

/* Electronic Commerce Inidcators */
#define ECI_SSL_SECURED         '7'
#define ECI_NON_SECURED         '8'
#define ECI_SET_NO_CERT         '6'
#define ECI_SET_WITH_CERT       '5'

/** File name types **/

#define OFFLINE_FILE_EXTN       ".adv"
#define ROC_FILE_EXTN           ".roc"
#define REVERSAL_FILE_EXTN      ".rev"
#define BACKUP_REV_FILE_EXTN    ".bak"

#define DEV_STDOUT "/dev/stdout"
#define STDOUT     1    /* Display output */

/*
 *		PROTOTYPES from GDS
 */
void vdInitGDS (void);
long lnGGErrorMessage (void);
void vdSGErrorMessage (long lnErrorMessage);

/** Format definitions **/

#define FILE_ID_FMT     "%s%02d"

//Global clock no longer required
#define NO_CLOCK_HANDLE			-1,
#define CHECK_TIMEOUT(time)         (((read_ticks())<time)?1:0)           

#define SEC_TO_MS(seconds)     (seconds*1000)


/** PerCent Formats - size of fractional element **/
#define WHOLE_PERCENT_FORMAT  0
#define TIP_FORMAT      2
#define TAX_FORMAT      3

//extern int errno;

#endif  /* DEF_DEFINED */

